

from Keyword import Keyword

web=Keyword()
web.openBrower()
web.visiturl('http://www.testingedu.com.cn:8000/index.php/Home/user/login.html')
#登录操作
web.input('//*[@id="username"]',"13800138006")
web.input('//*[@id="password"]',"123456")
web.input('//*[@id="verify_code"]',"1111")
web.sleep('1.5')
web.click('//a[@name="sbtbutton"]')
web.sleep('2')
#修改个人信息
# web.click("//li/a[text()='个人信息']")
# web.click('//*[@id="preview"]')
# web.swich_iframe('//iframe')
# web.input('(//input[@name="file"])[last()]',r"C:\_locales\p1.jpg")
# web.sleep("2")
# web.click('//div[text()="确定使用"]')
# web.sleep("2")
# web.swich_defauliframe()
# web.input('//*[@id="nickname"]','独孤九剑')
# web.click('//*[@id="man"]')
# web.input('//*[@id="birthday"]','1947-05-14')
# web.click('//input[@value="确认保存"]')
# web.sleep(5)
#新增地址
# web.click('//a[text()="地址管理"]')
# web.click('//span[text()="增加新地址"]')
# web.input('//*[@name="consignee"]','西门雪')
# web.input('//*[@name="mobile"]','18912345678')
# web.select('//*[@id="province"]',"广东省")
# web.select('//*[@id="city"]',"广州市")
# web.select('//*[@id="district"]',"番禺区")
# web.select('//*[@id="twon"]',"市桥街道")
# web.input('(//*[@placeholder="详细地址"])[1]','巨大大厦')
# web.input('//*[@name="zipcode"]','430017')
# web.click("//*[text()='保存']")
# web.sleep(1)
#删除地址
# web.click("//*[text()='西门雪']/../..//a[text()='删除']")
# web.sleep("1")
#搜索功能
web.input('//*[@id="q"]','手机')
web.click('//*[text()="搜索"]')
web.click('//*[contains(text(),"荣耀 畅玩6 2GB+16GB")]/../..//img')
web.click('//*[text()="加入购物车"]')
web.sleep('1')
web.click('//*[@class="layui-layer-setwin"]')
web.sleep("1")
web.movetoelement("//*[text()='我的购物车']")
web.click("//*[text()='去购物车结算 >>']")
web.click("//*[text()='去结算']")
web.sleep('1')
web.scroll_top()
web.click('//*[contains(text(),"  提交订单")]')
web.sleep("1")
text=web.gettext('//*[@class="succ-p"]')
orderid=web.getvalueByregular(text,'\d{18}?')
web.click('//*[text()="我的订单"]')
web.sleep("1")
web.swich_window('我的订单')
web.sleep("1")
web.input('//*[@id="search_key"]',orderid)
web.click('//*[@value="查询"]')
web.sleep("1")
web.click('//*[text()="立即支付"]')


